{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# GuaDerivations"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><div></div><div></div><div><strong>Installed Packages</strong><ul><li><span>YiJingFramework.EntityRelations, 4.0.1</span></li></ul></div></div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#r \"nuget:YiJingFramework.EntityRelations\"\n",
    "using YiJingFramework.EntityRelations.GuaDerivations.Extensions;\n",
    "using YiJingFramework.PrimitiveTypes;\n",
    "using YiJingFramework.PrimitiveTypes.GuaWithFixedCount;"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`YiJingFramework.EntityRelations.GuaDerivations` 命名空间主要提供卦的变换。举例而言："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "101011\n",
      "01011111\n",
      "10101111\n",
      "110100\n",
      "110100\n",
      "100 110\n",
      "11\n"
     ]
    }
   ],
   "source": [
    "Console.WriteLine(Gua.Parse(\"111111\").ChangeYaos(1, 2, 3, 2)); // 101011\n",
    "\n",
    "Console.WriteLine(Gua.Parse(\"10100000\").Cuogua()); // 01011111\n",
    "Console.WriteLine(Gua.Parse(\"11110101\").Zonggua()); // 10101111\n",
    "Console.WriteLine(GuaHexagram.Parse(\"111000\").Hugua()); // 110100\n",
    "Console.WriteLine(GuaHexagram.Parse(\"100110\").Jiaogua()); // 110100\n",
    "\n",
    "var s = Gua.Parse(\"10011011\").Split<GuaTrigram>(out var theRest);\n",
    "Console.WriteLine(string.Join(' ', s)); // 100 110\n",
    "Console.WriteLine(theRest); // 11"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "需要注意， `ChangeYaos` 方法是从 `0` 开始的，且如果同一个数字传入两次，那么对应的爻也会改变两次，最终效果是不发生改变。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".NET (C#)",
   "language": "C#",
   "name": ".net-csharp"
  },
  "language_info": {
   "file_extension": ".cs",
   "mimetype": "text/x-csharp",
   "name": "C#",
   "pygments_lexer": "csharp",
   "version": "3.12.2"
  },
  "polyglot_notebook": {
   "kernelInfo": {
    "defaultKernelName": "csharp",
    "items": [
     {
      "aliases": [],
      "name": "csharp"
     }
    ]
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
